<?php

header("Content-Type:json/html;charset=utf8;");
$config = require "../config.php";

$conn = new mysqli($config['servername'], $config['username'], $config['password'], $config['dbname']);
$sql = "select * from category";
$result = $conn->query($sql);
$conn->close();

if($result->num_rows>=1){
    $data = array();
    while ($row = $result->fetch_row())
    {
        $data[] = $row;
    }
    $result = ['code' =>1, 'data' => $data,  'msg' => "获取分类列表成功!"];
}else{
    $result = ['code' =>0,  'msg' => "获取分类列表失败!"];
}
print_r(json_encode($result));
